// SimpleWindow.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "SimpleWindow.h"

#include "..\..\winboost\winboost_all.hpp"

class dlg_about : public winboost::windows::dialog
{
public:
   dlg_about(void):
      winboost::windows::dialog(IDD_ABOUTBOX)
      {
         set_message_handler(WM_INITDIALOG, boost::bind(&dlg_about::on_init_dialog, this, _1));
         set_command_handler(IDOK, boost::bind(&dlg_about::on_ok, this));

         dex().set_control(IDC_STATIC_APP, &m_static);

         m_static.font().set_color(Gdiplus::Color::Maroon);
         m_static.font().set_alignment(Gdiplus::StringAlignmentNear);
         m_static.font().set_style(Gdiplus::FontStyleBold);
         m_static.font().set_size(11);
      }

private:
   winboost::windows::controls::label m_static;

   void on_ok(void)
   {
      close(IDOK);
   }

   LRESULT on_init_dialog(const winboost::events::message& e)
   {
      return 0;
   }
};

class my_app : public winboost::thread::application
{
public:
   my_app()
   {
      set_command_handler(IDM_ABOUT, boost::bind(&my_app::on_about, this));
   }

private:
   void on_about()
   {
      dlg_about dlg;
      dlg.show_modal();
   }
};

class my_wnd : public winboost::windows::basic_window
{
public:
   my_wnd()
   {
	   set_command_handler(IDM_EXIT, boost::bind(&my_wnd::on_exit, this));
   }

private:
   void on_exit()
   {
	   close();
   }

   
};



int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
   my_app app;
   my_wnd win;

   win.menu().set_id(IDC_SIMPLEWINDOW);
   win.set_title(_T("Hello"));

   win.show();
   return app.run();
}
